package my.learn.server.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import my.learn.server.entity.WechatUser;
import my.learn.server.lazy.standalone.infrastructure.entity.LazyNettyServerPermeateClientMappingDO;
import my.learn.server.service.ILazyNettyServerPermeateClientMappingDOService;
import my.learn.server.service.impl.UserServiceImpl;

import java.util.List;

/**
 * @Description TODO
 * @Author zhaotisheng
 * @Date 2025/4/13 17:34
 */
@RestController
@RequestMapping("s2c")
@Slf4j
public class ServerPermeateClientController{

    @Autowired
    ILazyNettyServerPermeateClientMappingDOService lazyNettyServerPermeateClientMappingDOService;

    @RequestMapping("list")
    public @ResponseBody String getAll() {
        log.info("list..");
        LambdaQueryWrapper<LazyNettyServerPermeateClientMappingDO> wrapper = new LambdaQueryWrapper<>();
        wrapper.select(LazyNettyServerPermeateClientMappingDO::getId
        ,LazyNettyServerPermeateClientMappingDO::getVisitorPort
        ,LazyNettyServerPermeateClientMappingDO::getClientId
                ,LazyNettyServerPermeateClientMappingDO::getServerId
                ,LazyNettyServerPermeateClientMappingDO::getClientTargetIp
                ,LazyNettyServerPermeateClientMappingDO::getClientTargetPort
                ,LazyNettyServerPermeateClientMappingDO::getVisitorPort
        );

        wrapper.eq(LazyNettyServerPermeateClientMappingDO::getIsDeleted,false);
        List<LazyNettyServerPermeateClientMappingDO> list = lazyNettyServerPermeateClientMappingDOService.list(wrapper);
        return /*JSONUtils.toJSONString*/(list.toString());
    }
}
